﻿using CollegeTecManageSystem.EntityFrameworkCore;
using EventBus.EntityFrameworkCore;
using Volo.Abp;
using Volo.Abp.AspNetCore.Mvc;
using Volo.Abp.Autofac;
using Volo.Abp.Modularity;

namespace EventBus
{
    [DependsOn(
    typeof(AbpAutofacModule),
        typeof(EventBusApplicationModule),
        typeof(EventBusEntityFrameworkCoreModule),
    typeof(AbpAspNetCoreMvcModule)
    )]
    public class EventBusModule:AbpModule
    {
        public override void ConfigureServices(ServiceConfigurationContext context)
        {
          

        }
        public override void OnApplicationInitialization(ApplicationInitializationContext context)
        {
         

            var app = context.GetApplicationBuilder();
            var env = context.GetEnvironment();

            var dbContext = app.ApplicationServices.GetRequiredService<EventBusDbContext>();
            dbContext.Database.EnsureCreated(); //自动创建数据库

            app.UseStaticFiles();

            app.UseRouting();

            app.UseAuthorization();

         
            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute(
                    name: "default",
                    pattern: "{controller=Home}/{action=Index}/{id?}");
                endpoints.MapControllerRoute(
            name: "areas",
            pattern: "{area:exists}/{controller=Home}/{action=Index}/{id?}"
          );
            });
        }
    }
}
